home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / textfiles / asm_opts < prev    next >
Internet Message Format  |  1994-11-23  |  54KB

  1. Path: newsroom.utas.edu.au!munnari.oz.au!spool.mu.edu!agate!msuinfo!harbinger.cc.monash.edu.au!bruce.cs.monash.edu.au!merlin!mel.dit.csiro.au!its.csiro.au!dmssyd.syd.dms.CSIRO.AU!metro!sunb.ocs.mq.edu.au!laurel.ocs.mq.edu.au!mglew
  2. From: mglew@laurel.ocs.mq.edu.au (Michael Glew)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: asp68k6.txt <file transmission>
  5. Date: 21 Jan 1994 04:25:54 GMT
  6. Organization: Macquarie University
  7. Lines: 1248
  8. Distribution: world
  9. Message-ID: <2hnlgi$6pl@sunb.ocs.mq.edu.au>
  10. NNTP-Posting-Host: laurel.ocs.mq.edu.au
  11.  
  12.               __
  13.              /_/\__
  14.              \ \ \ |\
  15.               ____\ \ \||__
  16.              / /  \\ \    __/
  17.             | | /\ \\ \ \
  18.             | | \/  \\_\/
  19.          ____\ \  /\ |
  20.         / /  \\ \ \/ |
  21.            | | /\/_\_\__/
  22.            | | \/  \
  23.         ____\ \  /\ |
  24.        / /    \\ \ \/ |       ASP68K PROJECT
  25.       /_/ /\ |\_\__/
  26.       \ \ \/ |        Sixth Edition
  27.        ____\ \    /
  28.       / /  \\ \ \         by Michael Glew
  29.      | | /\/_\ \ \         mglew@laurel.ocs.mq.edu.au
  30.      | | \/  \\_\/         Technophilia BBS +61-2-8073563
  31.   ____\_\__/\ |
  32.  / /  \ /_/\/ |       January 1994
  33. | | /\ \\_\__/
  34. | | \/    \
  35.  \ \  /\ \
  36.   \ \ \_\/
  37.    \ \ \
  38.     \_\/
  39.  
  40.  
  41. ---------------------------------------------------------------------------
  42.               C O N T R I B U T O R S
  43. ---------------------------------------------------------------------------
  44.  
  45.  
  46. Erik Bakke, Robert Barton, Bernd Blank, Kasimir Blomstedt, Frans Bouma,
  47. David Carson, Nicolas Dade, Aaron Digulla, Irmen de Jong, Andy Duplain,
  48. Denis Duplan, Steven Eker, Calle Englund, Alexander Fritsch, Charlie Gibbs,
  49. Kurt Haenen, Jon Hudson, Kjetil Jacobsen, Olav Kalgraf, Makoto Kamada,
  50. Markku Kolkka, John Lane, Jonathan Mahaffy, Dave Mc Mahan, Lindsay Meek,
  51. Walter Misar, Boerge Noest, Gunnar Rxnning, Jay Scott, Olaf Seibert,
  52. Peter Simons.
  53.  
  54.  
  55. ---------------------------------------------------------------------------
  56.               I N T R O D U C T I O N
  57. ---------------------------------------------------------------------------
  58.  
  59.  
  60. A while back, I was quite interested to find that there was an electronic
  61. magazine called "howtocode" that included lots of interesting hints and
  62. tips of coding.  In the fifth edition, there was a list of optimizations
  63. that really got be thinking.  "What if there was a proggy that you could
  64. put an assembler program through, that would speed it up, taking out all
  65. the stupid things output by compilers, and over-tired coders?" 8).  I
  66. started combing the networks, and came across one such program, called
  67. the "SELCO Source Optimizer".  It only had four optimizations, so I set
  68. to writing my own.
  69.  
  70. Step one was to collect as many optimization ideas as I could.  I posted
  71. to Usenet and got an impressive response, and the contributors are listed
  72. above.  I promised a report on the optimizations recieved, and here it
  73. is.  My aim now is to write a program to make these optimizations, and
  74. to distribute it.  Contributers will recieve a copy of the final archive,
  75. to thank them for their time and energy.  Further contributions will be
  76. welcomed, so rather than making changes yourself tell me what you want
  77. changed, and i'll distribute it with the next update.
  78.  
  79.  
  80. ---------------------------------------------------------------------------
  81.                    C H A N G E S
  82. ---------------------------------------------------------------------------
  83.  
  84.  
  85. 2nd Edition
  86.  
  87. The second edition incorporated a hell of a lot of corrections.  Double
  88. copies of some optimizations were incorporated in to just one copy, and
  89. a few additions were made.  Sorry that the first edition was not sent
  90. out to all contributors, but I was a tad busy. 8)
  91.  
  92.  
  93. 3rd Edition
  94.  
  95. Due to the distribution of the second edition document, many comments were
  96. recieved and a couple of the "optimizations" were found to be incorrect.
  97. Analysis of the mul/div optimizations ended in a few modifications for
  98. safety.  They still save a huge number of clock cycles, so it is better to
  99. be safe than sorry.
  100.  
  101. Also, I have made it so that the number of words of space saved or
  102. increased is shown.  Space savings are positive, increases are negative.
  103. Zero means no change.
  104.  
  105.  
  106. 4th Edition
  107.  
  108. Some minor changes and additions as well as the addition of columns for
  109. '030 and '040 CPUs - whole new format was required...
  110.  
  111.  
  112. 5th Edition
  113.  
  114. Eric Bakke released his docs on 020+ CPUs and 881/882 FPUs.  I have been
  115. given premission to use these docs to further the capabilities of asp68k.
  116. Thanks Eric...  I really would like to get a hold of the 020,030,040
  117. Programmer Reference Cards or manuals, so if anyone has any copies they
  118. wanna send me, let me know...  Local Motorola Distributers are not too
  119. helpful.
  120.  
  121.  
  122. 6th Edition
  123.  
  124. Aaron Digulla advised that it would be helpful if the optimizations were
  125. sorted somehow.  I will sort by the the first letters of the first line
  126. of the optimizations.  Also a special thanks to Makoto Kamada for his
  127. detailed contributions, without such this text would have died long ago..
  128.  
  129.  
  130. ---------------------------------------------------------------------------
  131.              O P T I M I Z A T I O N S
  132. ---------------------------------------------------------------------------
  133.  
  134.  
  135. Note:-
  136.  
  137.     m?        = memory operand
  138.     dx        = data register
  139.     ds        = data register (scratch)
  140.     ax        = address register
  141.     rx        = either a data or address register
  142.     #n        = immediate operand
  143.     ??,?1,?2= address label
  144.     *        = anything
  145.     .x        = any size
  146.     b<cc>   = branch commands
  147.  
  148.     Opt     = optimization
  149.     Notes   = notes about where optimization is valid, and misc notes
  150.     Speed   = are clock periods saved? ("Y" = yes
  151.                     "y" = in some cases
  152.                     "N" = no
  153.                     "*" = increase
  154.                     "-" = cannot be used on this cpu
  155.                     "!" = must be used on this cpu)
  156.     Size    = how many bytes are saved?
  157.  
  158. -------------------------------------------------------------
  159. Opt                        Speed     Size
  160.                      000 010 020 030 040
  161. ------------------------------------+---+---+---+---+---+----
  162. * ??* -> * n(pc)*            | Y | Y | ? | ? | ? | 2
  163. ------------------------------------+---+---+---+---+---+----
  164.  n = ??-pc, n < 32768
  165. ------------------------------------+---+---+---+---+---+----
  166. *0(ax)* -> *(ax)*            | Y | Y | ? | ? | ? | 2
  167. ------------------------------------+---+---+---+---+---+----
  168. add*.x #0,dx -> tst.x dx        | Y | Y | ? | ? | ? | 2/4
  169. ------------------------------------+---+---+---+---+---+----
  170. add.x #n,* -> addq.x #n,*        | Y | Y | ? | ? | ? | 2/4
  171. ------------------------------------+---+---+---+---+---+----
  172.  if 1 <= n <= 8
  173. ------------------------------------+---+---+---+---+---+----
  174. add.x #n,* -> subq.x #-n,*        | Y | Y | ? | ? | ? | 2/4
  175. ------------------------------------+---+---+---+---+---+----
  176.  -8 <= n <= -1
  177. ------------------------------------+---+---+---+---+---+----
  178. add.x #n,ax -> lea n(ax),ax        | Y | Y | ? | ? | ? | 0/2
  179. ------------------------------------+---+---+---+---+---+----
  180.  -32767 <= n <= -9, 9 <= n <= 32767
  181. ------------------------------------+---+---+---+---+---+----
  182. addq.l #n,ax -> addq.w #n,ax        | Y | Y | ? | ? | ? | 0
  183. ------------------------------------+---+---+---+---+---+----
  184. addq.l #n,ry -> add.l #(n+m),ry     | Y | Y | ? | ? | ? | -2
  185. addq.l #m,ry                |    |   |    |   |    |
  186. ------------------------------------+---+---+---+---+---+----
  187. addq.x #2,ax   -> move.w *,(ax)     | Y | Y | ? | Y | ? | 2
  188. move.w *,-(ax)                      |   |   |   |   |   |
  189. ------------------------------------+---+---+---+---+---+----
  190.  .x is .w or .l
  191. ------------------------------------+---+---+---+---+---+----
  192. addq.x #4,ax   -> move.l *,(ax)     | Y | Y | ? | Y | ? | 2
  193. move.l *,-(ax)                      |   |   |   |   |   |
  194. ------------------------------------+---+---+---+---+---+----
  195.  .x is .w or .l
  196. ------------------------------------+---+---+---+---+---+----
  197. addq.x #6,ax    -> move.w *1,4(ax)  | Y | Y | ? | ? | ? | 0
  198. move.w *1,-(ax)    move.l *2,(ax)   |   |   |   |   |   |
  199. move.l *2,-(ax)                     |   |   |   |   |   |
  200. ------------------------------------+---+---+---+---+---+----
  201.  .x is .w or .l
  202.  *1 and *2 do not contain ax
  203. ------------------------------------+---+---+---+---+---+----
  204. addq.x #6,ax    -> move.l *1,2(ax)  | Y | Y | ? | ? | ? | 0
  205. move.l *1,-(ax)    move.w *2,(ax)   |   |   |   |   |   |
  206. move.w *2,-(ax)                     |   |   |   |   |   |
  207. ------------------------------------+---+---+---+---+---+----
  208.  .x is .w or .l
  209.  *1 and *2 do not contain ax
  210. ------------------------------------+---+---+---+---+---+----
  211. addq.x #8,ax    -> move.l *1,4(ax)  | Y | Y | ? | ? | ? | 0
  212. move.l *1,-(ax)    move.l *2,(ax)   |   |   |   |   |   |
  213. move.l *2,-(ax)                     |   |   |   |   |   |
  214. ------------------------------------+---+---+---+---+---+----
  215.  .x is .w or .l
  216.  *1 and *2 do not contain ax
  217. ------------------------------------+---+---+---+---+---+----
  218. addq.x #4,sp -> move.l ax,(sp)      | Y | Y | ? | Y | ? | 2
  219. pea (ax)                            |   |   |   |   |   |
  220. ------------------------------------+---+---+---+---+---+----
  221.  .x is .w or .l
  222.  ax,ay are not a7(=sp)
  223. ------------------------------------+---+---+---+---+---+----
  224. addq.x #6,sp   -> move.w *,4(sp)    | Y | Y | ? | ? | ? | 0
  225. move.w *,-(sp)    move.l ax,(sp)    |   |   |   |   |   |
  226. pea (ax)                            |   |   |   |   |   |
  227. ------------------------------------+---+---+---+---+---+----
  228.  .x is .w or .l
  229.  ax,ay are not a7(=sp)
  230. ------------------------------------+---+---+---+---+---+----
  231. addq.x #6,sp   -> move.l ax,2(sp)   | Y | Y | ? | ? | ? | 0
  232. pea (ax)          move.w *,(sp)     |   |   |   |   |   |
  233. move.w *,-(sp)                      |   |   |   |   |   |
  234. ------------------------------------+---+---+---+---+---+----
  235.  .x is .w or .l
  236.  ax,ay are not a7(=sp)
  237. ------------------------------------+---+---+---+---+---+----
  238. addq.x #8,sp   -> move.l *,4(sp)    | Y | Y | ? | ? | ? | 0
  239. move.l *,-(sp)    move.l ax,(sp)    |   |   |   |   |   |
  240. pea (ax)                            |   |   |   |   |   |
  241. ------------------------------------+---+---+---+---+---+----
  242.  .x is .w or .l
  243.  ax,ay are not a7(=sp)
  244. ------------------------------------+---+---+---+---+---+----
  245. addq.x #8,sp   -> move.l ax,4(sp)   | Y | Y | ? | ? | ? | 0
  246. pea (ax)          move.l *,(sp)     |   |   |   |   |   |
  247. move.l *,-(sp)                      |   |   |   |   |   |
  248. ------------------------------------+---+---+---+---+---+----
  249.  .x is .w or .l
  250.  ax,ay are not a7(=sp)
  251. ------------------------------------+---+---+---+---+---+----
  252. addq.x #8,sp -> move.l ax,4(sp)     | Y | Y | ? | ? | ? | 0
  253. pea (ax)        move.l ay,(sp)      |   |   |   |   |   |
  254. pea (ay)                            |   |   |   |   |   |
  255. ------------------------------------+---+---+---+---+---+----
  256.  .x is .w or .l
  257.  ax,ay are not a7(=sp)
  258. ------------------------------------+---+---+---+---+---+----
  259. and.l #n,dx -> bclr.l #b,dx        | Y | Y | ? | ? | ? | 2
  260. ------------------------------------+---+---+---+---+---+----
  261. not(n) = 2^b (only 1 bit off)
  262. ------------------------------------+---+---+---+---+---+----
  263. asl.b #2,dy -> add.b dy,dy        | Y | Y | ? | ? | ? | -2
  264.            add.b dy,dy        |    |   |    |   |    |
  265. ------------------------------------+---+---+---+---+---+----
  266. asl.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  267. ------------------------------------+---+---+---+---+---+----
  268.  status flags are wrong, n>=8
  269. ------------------------------------+---+---+---+---+---+----
  270. asl.l #16,dx -> swap dx         | Y | Y | ? | ? | ? | -2
  271.         clr.w dx        |    |   |    |   |    |
  272. ------------------------------------+---+---+---+---+---+----
  273.  status flags are wrong
  274. ------------------------------------+---+---+---+---+---+----
  275. asl.l #n,dx -> asl.w #(n-16),dx     | Y | Y | ? | ? | ? | -4
  276.            swap dx            |    |   |    |   |    |
  277.            clr.w dx         |    |   |    |   |    |
  278. ------------------------------------+---+---+---+---+---+----
  279.  status flags are wrong, 16<n<32
  280. ------------------------------------+---+---+---+---+---+----
  281. asl.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  282. ------------------------------------+---+---+---+---+---+----
  283.  status flags are wrong, n>=32
  284. ------------------------------------+---+---+---+---+---+----
  285. asl.w #2,dy -> add.w dy,dy        | Y | Y | ? | ? | ? | -2
  286.            add.w dy,dy        |    |   |    |   |    |
  287. ------------------------------------+---+---+---+---+---+----
  288. asl.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  289. ------------------------------------+---+---+---+---+---+----
  290.  status flags are wrong, n>=16
  291. ------------------------------------+---+---+---+---+---+----
  292. asl.x #1,dy -> add.x dy,dy        | Y | Y | ? | ? | ? | 0
  293. ------------------------------------+---+---+---+---+---+----
  294. asr.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  295. ------------------------------------+---+---+---+---+---+----
  296.  status flags are wrong, n>=8
  297. ------------------------------------+---+---+---+---+---+----
  298. asr.l #16,dx -> swap dx         | Y | Y | ? | ? | ? | -2
  299.         ext.l dx        |    |   |    |   |    |
  300. ------------------------------------+---+---+---+---+---+----
  301.  status flags are wrong
  302. ------------------------------------+---+---+---+---+---+----
  303. asr.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  304. ------------------------------------+---+---+---+---+---+----
  305.  status flags are wrong, n>=32
  306. ------------------------------------+---+---+---+---+---+----
  307. asr.l #n,dx -> swap dx            | Y | Y | ? | ? | ? | -4
  308.            asr.w #(n-16),dx     |    |   |    |   |    |
  309.            ext.l dx         |    |   |    |   |    |
  310. ------------------------------------+---+---+---+---+---+----
  311.  status flags are wrong, 16<n<32
  312. ------------------------------------+---+---+---+---+---+----
  313. asr.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  314. ------------------------------------+---+---+---+---+---+----
  315.  status flags are wrong, n>=16
  316. ------------------------------------+---+---+---+---+---+----
  317. b<cc>.w ?? -> b<cc>.s ??        | Y | Y | ? | ? | ? | 2
  318. ------------------------------------+---+---+---+---+---+----
  319.  abs(??-pc)<128
  320. ------------------------------------+---+---+---+---+---+----
  321. bclr.l #n,dx -> and.w #m,dx         | Y | Y | ? | Y | ? | 0
  322. ------------------------------------+---+---+---+---+---+----
  323.  0 <= n <= 15, m = 65535-(2^n)
  324.  status flags are wrong
  325. ------------------------------------+---+---+---+---+---+----
  326. bra ?? -> (nothing)            | Y | Y | Y | ? | ? | 2/4
  327. ??      ??                |    |   |    |   |    |
  328. ------------------------------------+---+---+---+---+---+----
  329.  remove null branches, but keep the label
  330. ------------------------------------+---+---+---+---+---+----
  331. bset.b #7,m? -> tas m?              | y | y | ? | ? | ? | 2
  332. beq ??          bpl ??              |   |   |   |   |   |
  333. ------------------------------------+---+---+---+---+---+----
  334.  m? must be address allowing read-modify-write transfer.
  335.  Status flags are wrong
  336. ------------------------------------+---+---+---+---+---+----
  337. bset.b #7,m? -> tas m?              | y | y | ? | ? | ? | 2
  338. bne ??          bmi ??              |   |   |   |   |   |
  339. ------------------------------------+---+---+---+---+---+----
  340.  m? must be address allowing read-modify-write transfer.
  341.  Status flags are wrong
  342. ------------------------------------+---+---+---+---+---+----
  343. bset.b #7,m? -> tas m?              | y | y | ? | ? | ? | 2
  344. ------------------------------------+---+---+---+---+---+----
  345.  m? must be address allowing read-modify-write transfer.
  346.  Status flags are wrong
  347. ------------------------------------+---+---+---+---+---+----
  348. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | ? | 2
  349. beq ??          bpl ??              |   |   |   |   |   |
  350. ------------------------------------+---+---+---+---+---+----
  351.  status flags are wrong
  352. ------------------------------------+---+---+---+---+---+----
  353. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | ? | 2
  354. bne ??          bmi ??              |   |   |   |   |   |
  355. ------------------------------------+---+---+---+---+---+----
  356.  status flags are wrong
  357. ------------------------------------+---+---+---+---+---+----
  358. bset.l #7,dx -> tas dx              | Y | Y | ? | Y | ? | 2
  359. ------------------------------------+---+---+---+---+---+----
  360.  status flags are wrong
  361. ------------------------------------+---+---+---+---+---+----
  362. bset.l #n,dx -> or.w #m,dx          | Y | Y | ? | Y | ? | 0
  363. ------------------------------------+---+---+---+---+---+----
  364.  0 <= n <= 15, m = 2^n
  365.  status flags are wrong
  366. ------------------------------------+---+---+---+---+---+----
  367. bsr ?? -> bra ??            | Y | Y | ? | ? | ? | 2
  368. rts                    |    |   |    |   |    |
  369. ------------------------------------+---+---+---+---+---+----
  370.  different stack depth
  371. ------------------------------------+---+---+---+---+---+----
  372. btst.b #7,m? -> tst.b m?            | Y | Y | ? | ? | ? | 2
  373. beq ??          bpl ??              |   |   |   |   |   |
  374. ------------------------------------+---+---+---+---+---+----
  375.  Status flags are wrong.  Not valid for Dn, d16(PC), d8(PC,Xn)
  376.  dest address modes.
  377. ------------------------------------+---+---+---+---+---+----
  378. btst.b #7,m? -> tst.b m?            | Y | Y | ? | ? | ? | 2
  379. bne ??          bmi ??              |   |   |   |   |   |
  380. ------------------------------------+---+---+---+---+---+----
  381.  Status flags are wrong.  Not valid for Dn, d16(PC), d8(PC,Xn)
  382.  dest address modes.
  383. ------------------------------------+---+---+---+---+---+----
  384. btst.l #7,dx -> tst.b dx            | Y | Y | ? | Y | ? | 2
  385. beq ??          bpl ??              |   |   |   |   |   |
  386. ------------------------------------+---+---+---+---+---+----
  387.  Status flags are wrong.
  388. ------------------------------------+---+---+---+---+---+----
  389. btst.l #7,dx -> tst.b dx            | Y | Y | ? | Y | ? | 2
  390. bne ??          bmi ??              |   |   |   |   |   |
  391. ------------------------------------+---+---+---+---+---+----
  392.  Status flags are wrong.
  393. ------------------------------------+---+---+---+---+---+----
  394. btst.l #15,dx -> tst.w dx           | Y | Y | ? | Y | ? | 2
  395. beq ??           bpl ??             |   |   |   |   |   |
  396. ------------------------------------+---+---+---+---+---+----
  397.  Status flags are wrong.
  398. ------------------------------------+---+---+---+---+---+----
  399. btst.l #15,dx -> tst.w dx           | Y | Y | ? | Y | ? | 2
  400. bne ??           bmi ??             |   |   |   |   |   |
  401. ------------------------------------+---+---+---+---+---+----
  402.  Status flags are wrong.
  403. ------------------------------------+---+---+---+---+---+----
  404. btst.l #31,dx -> tst.l dx           | Y | Y | ? | Y | ? | 2
  405. beq ??           bpl ??             |   |   |   |   |   |
  406. ------------------------------------+---+---+---+---+---+----
  407.  Status flags are wrong.
  408. ------------------------------------+---+---+---+---+---+----
  409. btst.l #31,dx -> tst.l dx           | Y | Y | ? | Y | ? | 2
  410. bne ??           bmi ??             |   |   |   |   |   |
  411. ------------------------------------+---+---+---+---+---+----
  412.  status flags are wrong
  413. ------------------------------------+---+---+---+---+---+----
  414. clr.b mn   -> clr.w mn            | Y | Y | ? | ? | ? | 2/4/6
  415. clr.b mn+1                |    |   |    |   |    |
  416. ------------------------------------+---+---+---+---+---+----
  417.  best if mn is longword aligned
  418. ------------------------------------+---+---+---+---+---+----
  419. clr.l dx -> moveq #0,dx         | Y | Y | ? | ? | ? | 0
  420. ------------------------------------+---+---+---+---+---+----
  421. clr.w mn   -> clr.l mn            | Y | Y | ? | ? | ? | 2/4/6
  422. clr.w mn+2                |    |   |    |   |    |
  423. ------------------------------------+---+---+---+---+---+----
  424.  best if mn is longword aligned
  425. ------------------------------------+---+---+---+---+---+----
  426. clr.x -(ax) -> move.x ds,-(ax)        | Y | Y | ? | ? | ? | 0
  427. ------------------------------------+---+---+---+---+---+----
  428.  ds must equal zero
  429. ------------------------------------+---+---+---+---+---+----
  430. clr.x n(ax,rx) -> move.x ds,n(ax,rx)| Y | Y | ? | ? | ? | 0
  431. ------------------------------------+---+---+---+---+---+----
  432.  ds must equal zero
  433. ------------------------------------+---+---+---+---+---+----
  434. cmp.x #0,ax -> move.x ax,ds        | Y | Y | ? | ? | ? | 2/4
  435. ------------------------------------+---+---+---+---+---+----
  436.  move ax to scratch register
  437. ------------------------------------+---+---+---+---+---+----
  438. cmp.x #0,ax -> tst.x ax             | - | - | ? | ? | ? | ?
  439. ------------------------------------+---+---+---+---+---+----
  440. for .w and .l
  441. ------------------------------------+---+---+---+---+---+----
  442. cmp.x #0,dx -> tst.x dx         | Y | Y | ? | ? | ? | 2/4
  443. ------------------------------------+---+---+---+---+---+----
  444. cmp.x #0,m? -> tst.x m?         | Y | Y | ? | ? | ? | 2/4
  445. ------------------------------------+---+---+---+---+---+----
  446. may not be legal on some early '000 CPUs
  447. ------------------------------------+---+---+---+---+---+----
  448. divu.l #n,dx -> lsr.l #m,dx        | ! | ! | ? | ? | ? | 4
  449. ------------------------------------+---+---+---+---+---+----
  450.  n is 2^m, 1 <= m <= 8
  451. ------------------------------------+---+---+---+---+---+----
  452. divu.l #n,dx -> moveq #0,dx        | ! | ! | ? | ? | ? | 4
  453. ------------------------------------+---+---+---+---+---+----
  454.  n is 2^m, m>=32
  455. ------------------------------------+---+---+---+---+---+----
  456. divu.l #n,dx -> moveq #m,ds        | ! | ! | ? | ? | ? | 2
  457.         lsr.l ds,dx        |    |   |    |   |    |
  458. ------------------------------------+---+---+---+---+---+----
  459.  n is 2^m, 8<m<32
  460. ------------------------------------+---+---+---+---+---+----
  461. divu.w #n,dx -> lsr.l #m,dx        | Y | Y | ? | ? | ? | 2
  462. ------------------------------------+---+---+---+---+---+----
  463.  n is 2^m, 1 <= m <= 8, ignore remainder
  464. ------------------------------------+---+---+---+---+---+----
  465. divu.w #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 2
  466. ------------------------------------+---+---+---+---+---+----
  467.  n is 2^m, m>=32
  468. ------------------------------------+---+---+---+---+---+----
  469. divu.w #n,dx -> moveq #m,ds        | Y | Y | ? | ? | ? | 0
  470.         lsr.l ds,dx        |    |   |    |   |    |
  471. ------------------------------------+---+---+---+---+---+----
  472.  n is 2^m, 8<m<32, ignore remainder
  473. ------------------------------------+---+---+---+---+---+----
  474. eor.x #-1,* -> not.x *            | Y | Y | ? | ? | ? | 2/4
  475. ------------------------------------+---+---+---+---+---+----
  476. ext.w dx -> extb.l dx            | - | - | ? | ? | ? | 2
  477. ext.l dx                |    |   |    |   |    |
  478. ------------------------------------+---+---+---+---+---+----
  479. jmp ?? -> bra.w ??            | Y | Y | ? | ? | ? | 2
  480. ------------------------------------+---+---+---+---+---+----
  481.  abs(??-pc) < 32768, same section
  482. ------------------------------------+---+---+---+---+---+----
  483. jsr * -> jmp *                | Y | Y | ? | ? | ? | 2
  484. rts                    |    |   |    |   |    |
  485. ------------------------------------+---+---+---+---+---+----
  486.  different stack depth
  487. ------------------------------------+---+---+---+---+---+----
  488. jsr ?1 -> pea ?2            | y | y | ? | ? | ? | 0
  489. jmp ?2    jmp ?1            |    |   |    |   |    |
  490. ------------------------------------+---+---+---+---+---+----
  491.  same time if jsr is abs.l
  492. ------------------------------------+---+---+---+---+---+----
  493. jsr ?? -> bsr.w ??            | Y | Y | ? | ? | ? | 2
  494. ------------------------------------+---+---+---+---+---+----
  495.  abs(??-pc) < 32768, same section
  496. ------------------------------------+---+---+---+---+---+----
  497. lea (ax),ax -> (nothing)        | Y | Y | Y | ? | ? | 2
  498. ------------------------------------+---+---+---+---+---+----
  499.  delete
  500. ------------------------------------+---+---+---+---+---+----
  501. lea 0.w,ax -> sub.l ax,ax        | Y | Y | - | - | - | 2
  502. ------------------------------------+---+---+---+---+---+----
  503. lea n(ax),ax -> addq.w #n,ax        | Y | Y | ? | ? | ? | 2
  504. ------------------------------------+---+---+---+---+---+----
  505.  if 1 <= n <= 8
  506. ------------------------------------+---+---+---+---+---+----
  507. lea n(ax),ax -> subq.w #-n,ax        | Y | Y | ? | ? | ? | 2
  508. ------------------------------------+---+---+---+---+---+----
  509.  if -8 <= n <= -1
  510. ------------------------------------+---+---+---+---+---+----
  511. lsl.b #2,dy -> add.b dy,dy        | Y | Y | ? | ? | ? | -2
  512.            add.b dy,dy        |    |   |    |   |    |
  513. ------------------------------------+---+---+---+---+---+----
  514. lsl.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  515. ------------------------------------+---+---+---+---+---+----
  516.  status flags are wrong, n>=8
  517. ------------------------------------+---+---+---+---+---+----
  518. lsl.l #16,dx -> swap dx         | Y | Y | ? | ? | ? | -2
  519.         clr.w dx        |    |   |    |   |    |
  520. ------------------------------------+---+---+---+---+---+----
  521.  status flags are wrong
  522. ------------------------------------+---+---+---+---+---+----
  523. lsl.l #n,dx -> lsl.w #(n-16),dx     | Y | Y | ? | ? | ? | -4
  524.            swap dx            |    |   |    |   |    |
  525.            clr.w dx         |    |   |    |   |    |
  526. ------------------------------------+---+---+---+---+---+----
  527.  status flags are wrong, 16<n<32
  528. ------------------------------------+---+---+---+---+---+----
  529. lsl.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  530. ------------------------------------+---+---+---+---+---+----
  531.  status flags are wrong, n>=32
  532. ------------------------------------+---+---+---+---+---+----
  533. lsl.w #2,dy -> add.w dy,dy        | Y | Y | ? | ? | ? | -2
  534.            add.w dy,dy        |    |   |    |   |    |
  535. ------------------------------------+---+---+---+---+---+----
  536. lsl.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  537. ------------------------------------+---+---+---+---+---+----
  538.  status flags are wrong, n>=16
  539. ------------------------------------+---+---+---+---+---+----
  540. lsl.x #1,dy -> add.x dy,dy        | Y | Y | ? | ? | ? | 0
  541. ------------------------------------+---+---+---+---+---+----
  542. lsr.b #n,dx -> clr.b dx         | Y | Y | ? | ? | ? | 0
  543. ------------------------------------+---+---+---+---+---+----
  544.  status flags are wrong, n>=8
  545. ------------------------------------+---+---+---+---+---+----
  546. lsr.l #16,dx -> clr.w dx        | Y | Y | ? | ? | ? | -2
  547.         swap dx         |    |   |    |   |    |
  548. ------------------------------------+---+---+---+---+---+----
  549.  status flags are wrong
  550. ------------------------------------+---+---+---+---+---+----
  551. lsr.l #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | -4
  552.            swap dx            |    |   |    |   |    |
  553.            lsr.w #(n-16),dx     |    |   |    |   |    |
  554. ------------------------------------+---+---+---+---+---+----
  555.  status flags are wrong, 16<n<32
  556. ------------------------------------+---+---+---+---+---+----
  557. lsr.l #n,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 0
  558. ------------------------------------+---+---+---+---+---+----
  559.  status flags are wrong, n>=32
  560. ------------------------------------+---+---+---+---+---+----
  561. lsr.w #n,dx -> clr.w dx         | Y | Y | ? | ? | ? | 0
  562. ------------------------------------+---+---+---+---+---+----
  563.  status flags are wrong, n>=16
  564. ------------------------------------+---+---+---+---+---+----
  565. move.b #-1,(ax) -> st (ax)        | Y | Y | ? | ? | ? | 2
  566. ------------------------------------+---+---+---+---+---+----
  567.  status flags are wrong
  568. ------------------------------------+---+---+---+---+---+----
  569. move.b #-1,(ax)+ -> st (ax)+        | N | N | ? | ? | ? | 2
  570. ------------------------------------+---+---+---+---+---+----
  571.  status flags are wrong
  572. ------------------------------------+---+---+---+---+---+----
  573. move.b #-1,-(ax) -> st -(ax)        | N | N | ? | ? | ? | 2
  574. ------------------------------------+---+---+---+---+---+----
  575.  status flags are wrong
  576. ------------------------------------+---+---+---+---+---+----
  577. move.b #-1,?? -> st ??            | Y | Y | ? | ? | ? | 2
  578. ------------------------------------+---+---+---+---+---+----
  579.  status flags are wrong
  580. ------------------------------------+---+---+---+---+---+----
  581. move.b #-1,dx -> st dx            | Y | Y | ? | ? | ? | 2
  582. ------------------------------------+---+---+---+---+---+----
  583.  status flags are wrong
  584. ------------------------------------+---+---+---+---+---+----
  585. move.b #-1,n(ax) -> st n(ax)        | Y | Y | ? | ? | ? | 2
  586. ------------------------------------+---+---+---+---+---+----
  587.  status flags are wrong
  588. ------------------------------------+---+---+---+---+---+----
  589. move.b #-1,n(ax,rx) -> st n(ax,rx)  | Y | Y | ? | ? | ? | 2
  590. ------------------------------------+---+---+---+---+---+----
  591.  status flags are wrong
  592. ------------------------------------+---+---+---+---+---+----
  593. move.b #x,mn   -> move.w #xy,mn     | Y | Y | ? | ? | ? | 4/6/8
  594. move.b #y,mn+1                |    |   |    |   |    |
  595. ------------------------------------+---+---+---+---+---+----
  596.  best if mn is longword aligned
  597. ------------------------------------+---+---+---+---+---+----
  598. move.l #n,-(sp) -> pea n.w        | Y | Y | ? | ? | ? | 2
  599. ------------------------------------+---+---+---+---+---+----
  600.  -32767 <= n <= 32767
  601. ------------------------------------+---+---+---+---+---+----
  602. move.l #n,ax -> move.w #n,ax        | Y | Y | ? | ? | ? | 2
  603. ------------------------------------+---+---+---+---+---+----
  604.  -32767 <= n <= 32767
  605. ------------------------------------+---+---+---+---+---+----
  606. move.l #n,dx -> moveq #-128,dx        | Y | Y | ? | N | * | 2
  607.         subq.l #n+128,dx    |    |   |    |   |    |
  608. ------------------------------------+---+---+---+---+---+----
  609.  -136 <= n <= -129
  610. ------------------------------------+---+---+---+---+---+----
  611. move.l #n,dx -> moveq #m,dx        | Y | Y | ? | ? | ? | 2
  612.         not.b dx        |    |   |    |   |    |
  613. ------------------------------------+---+---+---+---+---+----
  614.  128 <= n <= 255, m = 255-n
  615. ------------------------------------+---+---+---+---+---+----
  616. move.l #n,dx -> moveq #m,dx        | Y | Y | ? | ? | ? | 2
  617.         not.w dx        |    |   |    |   |    |
  618.                     |    |   |    |   |    |
  619. ------------------------------------+---+---+---+---+---+----
  620.  65534 <= n <= 65408 or -65409 <= n <= -65536, m = 65535-abs(n)
  621. ------------------------------------+---+---+---+---+---+----
  622. move.l #n,dx -> moveq #m,dx        | Y | Y | ? | ? | ? | 2
  623.         swap dx         |    |   |    |   |    |
  624.                     |    |   |    |   |    |
  625. ------------------------------------+---+---+---+---+---+----
  626.  -8323073 <= n <= -65537 or 4096 <= n <= 8323072, n = m*65536
  627. ------------------------------------+---+---+---+---+---+----
  628. move.l #n,dx -> moveq #n,dx        | Y | Y | ? | ? | ? | 4
  629. ------------------------------------+---+---+---+---+---+----
  630.  if -128 <= n <= 127
  631. ------------------------------------+---+---+---+---+---+----
  632. move.l #n,dx -> moveq #y,dx        | * | * | ? | ? | ? | 2
  633.         lsl.l #z,dx        |    |   |    |   |    |
  634. ------------------------------------+---+---+---+---+---+----
  635.  n = y * 2^z
  636. ------------------------------------+---+---+---+---+---+----
  637. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | N | ? | 2
  638.                 add.b dx,dx         |   |   |   |   |   |
  639. ------------------------------------+---+---+---+---+---+----
  640.  (128 <= n <= 254 or -256 <= n <= -130) and n is even, m = n/2
  641. ------------------------------------+---+---+---+---+---+----
  642. move.l #n,dx -> moveq #m,dx         | Y | Y | ? | * | ? | 2
  643.                 bchg.l dx,dx        |   |   |   |   |   |
  644. ------------------------------------+---+---+---+---+---+----
  645.  n = -32881 -> m = -113
  646.  n = -32849 -> m = -81
  647.  n = -32817 -> m = -49
  648.  n = -32785 -> m = -17
  649.  n = -16498 -> m = -114
  650.  n = -16466 -> m = -82
  651.  n = -16434 -> m = -50
  652.  n = -16402 -> m = -18
  653.  n = -8307 -> m = -115
  654.  n = -8275 -> m = -83
  655.  n = -8243 -> m = -51
  656.  n = -8211 -> m = -19
  657.  n = -4212 -> m = -116
  658.  n = -4180 -> m = -84
  659.  n = -4148 -> m = -52
  660.  n = -4116 -> m = -20
  661.  n = -2165 -> m = -117
  662.  n = -2133 -> m = -85
  663.  n = -2101 -> m = -53
  664.  n = -2069 -> m = -21
  665.  n = -1142 -> m = -118
  666.  n = -1110 -> m = -86
  667.  n = -1078 -> m = -54
  668.  n = -1046 -> m = -22
  669.  n = -631 -> m = -119
  670.  n = -599 -> m = -87
  671.  n = -567 -> m = -55
  672.  n = -535 -> m = -23
  673.  n = -376 -> m = -120
  674.  n = -344 -> m = -88
  675.  n = -312 -> m = -56
  676.  n = -280 -> m = -24
  677.  n = 264 -> m = 8
  678.  n = 296 -> m = 40
  679.  n = 328 -> m = 72
  680.  n = 360 -> m = 104
  681.  n = 521 -> m = 9
  682.  n = 553 -> m = 41
  683.  n = 585 -> m = 73
  684.  n = 617 -> m = 105
  685.  n = 1034 -> m = 10
  686.  n = 1066 -> m = 42
  687.  n = 1098 -> m = 74
  688.  n = 1130 -> m = 106
  689.  n = 2059 -> m = 11
  690.  n = 2091 -> m = 43
  691.  n = 2123 -> m = 75
  692.  n = 2155 -> m = 107
  693.  n = 4108 -> m = 12
  694.  n = 4140 -> m = 44
  695.  n = 4172 -> m = 76
  696.  n = 4204 -> m = 108
  697.  n = 8205 -> m = 13
  698.  n = 8237 -> m = 45
  699.  n = 8269 -> m = 77
  700.  n = 8301 -> m = 109
  701.  n = 16398 -> m = 14
  702.  n = 16430 -> m = 46
  703.  n = 16462 -> m = 78
  704.  n = 16494 -> m = 110
  705.  n = 32783 -> m = 15
  706.  n = 32815 -> m = 47
  707.  n = 32847 -> m = 79
  708.  n = 32879 -> m = 111
  709. ------------------------------------+---+---+---+---+---+----
  710. move.l #n,dx -> moveq #m,dx         | N | N | ? | * | ? | 2
  711.                 bchg.l dx,dx        |   |   |   |   |   |
  712. ------------------------------------+---+---+---+---+---+----
  713.  n = -2147483617 -> m = 31
  714.  n = -2147483585 -> m = 63
  715.  n = -2147483553 -> m = 95
  716.  n = -2147483521 -> m = 127
  717.  n = -1073741922 -> m = -98
  718.  n = -1073741890 -> m = -66
  719.  n = -1073741858 -> m = -34
  720.  n = -1073741826 -> m = -2
  721.  n = -536871011 -> m = -99
  722.  n = -536870979 -> m = -67
  723.  n = -536870947 -> m = -35
  724.  n = -536870915 -> m = -3
  725.  n = -268435556 -> m = -100
  726.  n = -268435524 -> m = -68
  727.  n = -268435492 -> m = -36
  728.  n = -268435460 -> m = -4
  729.  n = -134217829 -> m = -101
  730.  n = -134217797 -> m = -69
  731.  n = -134217765 -> m = -37
  732.  n = -134217733 -> m = -5
  733.  n = -67108966 -> m = -102
  734.  n = -67108934 -> m = -70
  735.  n = -67108902 -> m = -38
  736.  n = -67108870 -> m = -6
  737.  n = -33554535 -> m = -103
  738.  n = -33554503 -> m = -71
  739.  n = -33554471 -> m = -39
  740.  n = -33554439 -> m = -7
  741.  n = -16777320 -> m = -104
  742.  n = -16777288 -> m = -72
  743.  n = -16777256 -> m = -40
  744.  n = -16777224 -> m = -8
  745.  n = -8388713 -> m = -105
  746.  n = -8388681 -> m = -73
  747.  n = -8388649 -> m = -41
  748.  n = -8388617 -> m = -9
  749.  n = -4194410 -> m = -106
  750.  n = -4194378 -> m = -74
  751.  n = -4194346 -> m = -42
  752.  n = -4194314 -> m = -10
  753.  n = -2097259 -> m = -107
  754.  n = -2097227 -> m = -75
  755.  n = -2097195 -> m = -43
  756.  n = -2097163 -> m = -11
  757.  n = -1048684 -> m = -108
  758.  n = -1048652 -> m = -76
  759.  n = -1048620 -> m = -44
  760.  n = -1048588 -> m = -12
  761.  n = -524397 -> m = -109
  762.  n = -524365 -> m = -77
  763.  n = -524333 -> m = -45
  764.  n = -524301 -> m = -13
  765.  n = -262254 -> m = -110
  766.  n = -262222 -> m = -78
  767.  n = -262190 -> m = -46
  768.  n = -262158 -> m = -14
  769.  n = -131183 -> m = -111
  770.  n = -131151 -> m = -79
  771.  n = -131119 -> m = -47
  772.  n = -131087 -> m = -15
  773.  n = -65648 -> m = -112
  774.  n = -65616 -> m = -80
  775.  n = -65584 -> m = -48
  776.  n = -65552 -> m = -16
  777.  n = 65552 -> m = 16
  778.  n = 65584 -> m = 48
  779.  n = 65616 -> m = 80
  780.  n = 65648 -> m = 112
  781.  n = 131089 -> m = 17
  782.  n = 131121 -> m = 49
  783.  n = 131153 -> m = 81
  784.  n = 131185 -> m = 113
  785.  n = 262162 -> m = 18
  786.  n = 262194 -> m = 50
  787.  n = 262226 -> m = 82
  788.  n = 262258 -> m = 114
  789.  n = 524307 -> m = 19
  790.  n = 524339 -> m = 51
  791.  n = 524371 -> m = 83
  792.  n = 524403 -> m = 115
  793.  n = 1048596 -> m = 20
  794.  n = 1048628 -> m = 52
  795.  n = 1048660 -> m = 84
  796.  n = 1048692 -> m = 116
  797.  n = 2097173 -> m = 21
  798.  n = 2097205 -> m = 53
  799.  n = 2097237 -> m = 85
  800.  n = 2097269 -> m = 117
  801.  n = 4194326 -> m = 22
  802.  n = 4194358 -> m = 54
  803.  n = 4194390 -> m = 86
  804.  n = 4194422 -> m = 118
  805.  n = 8388631 -> m = 23
  806.  n = 8388663 -> m = 55
  807.  n = 8388695 -> m = 87
  808.  n = 8388727 -> m = 119
  809.  n = 16777240 -> m = 24
  810.  n = 16777272 -> m = 56
  811.  n = 16777304 -> m = 88
  812.  n = 16777336 -> m = 120
  813.  n = 33554457 -> m = 25
  814.  n = 33554489 -> m = 57
  815.  n = 33554521 -> m = 89
  816.  n = 33554553 -> m = 121
  817.  n = 67108890 -> m = 26
  818.  n = 67108922 -> m = 58
  819.  n = 67108954 -> m = 90
  820.  n = 67108986 -> m = 122
  821.  n = 134217755 -> m = 27
  822.  n = 134217787 -> m = 59
  823.  n = 134217819 -> m = 91
  824.  n = 134217851 -> m = 123
  825.  n = 268435484 -> m = 28
  826.  n = 268435516 -> m = 60
  827.  n = 268435548 -> m = 92
  828.  n = 268435580 -> m = 124
  829.  n = 536870941 -> m = 29
  830.  n = 536870973 -> m = 61
  831.  n = 536871005 -> m = 93
  832.  n = 536871037 -> m = 125
  833.  n = 1073741854 -> m = 30
  834.  n = 1073741886 -> m = 62
  835.  n = 1073741918 -> m = 94
  836.  n = 1073741950 -> m = 126
  837.  n = 2147483551 -> m = -97
  838.  n = 2147483583 -> m = -65
  839.  n = 2147483615 -> m = -33
  840.  n = 2147483647 -> m = -1
  841. ------------------------------------+---+---+---+---+---+----
  842. move.l #n,m? -> moveq  #n,ds        | Y | Y | ? | ? | ? | 2
  843.         move.l ds,m?        |    |   |    |   |    |
  844. ------------------------------------+---+---+---+---+---+----
  845.  -128 <= n <= 127
  846. ------------------------------------+---+---+---+---+---+----
  847. move.l (ax),ay -> move.x ([ax],n),dz| - | - | ? | ? | ? | ?
  848. move.x n(ay),dz             |    |   |    |   |    |
  849. ------------------------------------+---+---+---+---+---+----
  850. move.l (ax),ay -> move.x ([ax]),dz  | - | - | ? | ? | ? | ?
  851. move.x (ay),dz                |    |   |    |   |    |
  852. ------------------------------------+---+---+---+---+---+----
  853. move.l (bd.x,ax),dy ->            | - | - | ? | ? | ? | ?
  854.              move.l bd.x,dy |    |   |    |   |    |
  855. ------------------------------------+---+---+---+---+---+----
  856. move.l (n.w,ax),dy ->            | - | - | ? | ? | ? | ?
  857.             move.l n(ax),dy |    |   |    |   |    |
  858. ------------------------------------+---+---+---+---+---+----
  859. move.l (sp),(n,sp) -> rtd #n        | - | - | ? | ? | ? | ?
  860. lea (n,sp),sp                |    |   |    |   |    |
  861. rts                    |    |   |    |   |    |
  862. ------------------------------------+---+---+---+---+---+----
  863. move.l (sp),0(dx,sp) -> rtd dx        | - | Y | ? | ? | ? | 6
  864. lea 0(dx,sp),sp                |    |   |    |   |    |
  865. rts                    |    |   |    |   |    |
  866. ------------------------------------+---+---+---+---+---+----
  867. move.l 12(ax),12(ay) -> move16        | - | - | - | - | ? | ?
  868. move.l 8(ax),8(ay)    (ax)+,(ay)+ |    |   |    |   |    |
  869. move.l 4(ax),4(ay)            |    |   |    |   |    |
  870. move.l (ax)+,(ay)+            |    |   |    |   |    |
  871. ------------------------------------+---+---+---+---+---+----
  872. move.l ax,-(sp) -> link ax,#n        | Y | Y | ? | ? | ? | 4
  873. move.l sp,ax                |    |   |    |   |    |
  874. add.w #n,sp                |    |   |    |   |    |
  875. ------------------------------------+---+---+---+---+---+----
  876.  -32767 <= n <= 32767
  877. ------------------------------------+---+---+---+---+---+----
  878. move.l ax,-(sp) -> pea -n(ax)        | Y | Y | ? | ? | ? | 0/4
  879. sub*.l #n,(sp)                |    |   |    |   |    |
  880. ------------------------------------+---+---+---+---+---+----
  881. move.l ax,-(sp) -> pea n(ax)        | Y | Y | ? | ? | ? | 0/4
  882. add*.l #n,(sp)                |    |   |    |   |    |
  883. ------------------------------------+---+---+---+---+---+----
  884. move.l ax,az -> lea n(ax.l*4),az    | - | - | ? | ? | ? | ?
  885. asl.l #2,az                |    |   |    |   |    |
  886. add.x #n,az                |    |   |    |   |    |
  887. ------------------------------------+---+---+---+---+---+----
  888.  az=n+4*ax, -128<=n<=127
  889. ------------------------------------+---+---+---+---+---+----
  890. move.l ax,az -> lea n(ax.l*8),az    | - | - | ? | ? | ? | ?
  891. asl.l #3,az                |    |   |    |   |    |
  892. add.x #n,az                |    |   |    |   |    |
  893. ------------------------------------+---+---+---+---+---+----
  894.  az=n+8*ax, -32767<=n<=32767
  895. ------------------------------------+---+---+---+---+---+----
  896. move.l ax,sp -> unlk ax         | Y | Y | ? | ? | ? | 2
  897. move.l (sp)+,ax             |    |   |    |   |    |
  898. ------------------------------------+---+---+---+---+---+----
  899. move.l ay,az -> lea n(ax,ay.l*4),az | - | - | ? | ? | ? | ?
  900. asl.l #2,az                |    |   |    |   |    |
  901. add.l ax,az                |    |   |    |   |    |
  902. add.x #n,az                |    |   |    |   |    |
  903. ------------------------------------+---+---+---+---+---+----
  904.  az=n+ax+4*ay, -32767<=n<=32767
  905. ------------------------------------+---+---+---+---+---+----
  906. move.l ay,az -> lea n(ax,ay.l*8),az | - | - | ? | ? | ? | ?
  907. asl.l #3,az                |    |   |    |   |    |
  908. add.l ax,az                |    |   |    |   |    |
  909. add.x #n,az                |    |   |    |   |    |
  910. ------------------------------------+---+---+---+---+---+----
  911.  az=n+ax+8*ay, -32767<=n<=32767
  912. ------------------------------------+---+---+---+---+---+----
  913. move.w #x,mn   -> move.l #xy,mn     | Y | Y | ? | ? | ? | 2/4/6
  914. move.w #y,mn+2                |    |   |    |   |    |
  915. ------------------------------------+---+---+---+---+---+----
  916.  best if mn is longword aligned
  917. ------------------------------------+---+---+---+---+---+----
  918. move.x #0,ax -> sub.l ax,ax        | Y | Y | ? | ? | ? | 2/4
  919. ------------------------------------+---+---+---+---+---+----
  920. move.x #n,ax -> lea n,ax        | Y | Y | ? | ? | ? | 0
  921. ------------------------------------+---+---+---+---+---+----
  922.  n <> 0
  923. ------------------------------------+---+---+---+---+---+----
  924. move.x (rx,ay),az -> move.x ay,az   | Y | Y | ? | ? | ? | 0
  925.              add.x rx,az    |    |   |    |   |    |
  926. ------------------------------------+---+---+---+---+---+----
  927. move.x ax,ay -> lea n(ax),ay        | Y | Y | ? | ? | ? | 2/4
  928. add.x #n,ay                |    |   |    |   |    |
  929. ------------------------------------+---+---+---+---+---+----
  930.  -32767 <= n <= 32767
  931. ------------------------------------+---+---+---+---+---+----
  932. move.x ax,az -> lea -n(ax,ay),az    | Y | Y | ? | ? | ? | 2
  933. sub.x #n,az                |    |   |    |   |    |
  934. add.x ay,az                |    |   |    |   |    |
  935. ------------------------------------+---+---+---+---+---+----
  936.  az=n+ax+ay, n<=32767
  937. ------------------------------------+---+---+---+---+---+----
  938. move.x ax,az -> lea n(ax,ay),az     | Y | Y | ? | ? | ? | 2
  939. add.x #n,az                |    |   |    |   |    |
  940. add.x ay,az                |    |   |    |   |    |
  941. ------------------------------------+---+---+---+---+---+----
  942.  az=n+ax+ay, n<=32767
  943. ------------------------------------+---+---+---+---+---+----
  944. movem.l (ax)+,registers         | * | * | ? | ? | Y | *
  945.          -> move.l (ax)+,ry |    |   |    |   |    |
  946.                for each reg |    |   |    |   |    |
  947. ------------------------------------+---+---+---+---+---+----
  948. movem.w *,dx -> move.w *,dx        | Y | Y | ? | ? | ? | 0
  949.         ext.l dx        |    |   |    |   |    |
  950. ------------------------------------+---+---+---+---+---+----
  951. movem.x *,@ -> move.x *,@        | Y | Y | ? | ? | ? | 2
  952.                     |    |   |    |   |    |
  953. ------------------------------------+---+---+---+---+---+----
  954.  @ = a single register, not (@=dx & .x=.w)
  955. ------------------------------------+---+---+---+---+---+----
  956. movem.x @,* -> move.x @,*        | Y | Y | ? | ? | ? | 2
  957.                     |    |   |    |   |    |
  958. ------------------------------------+---+---+---+---+---+----
  959.  @ = a single register, status flags are wrong
  960. ------------------------------------+---+---+---+---+---+----
  961. moveq #n,az -> lea n(ax,ay.l*2),az  | - | - | ? | ? | ? | ?
  962. add.x ay,az                |    |   |    |   |    |
  963. add.x ax,az                |    |   |    |   |    |
  964. add.x ay,az                |    |   |    |   |    |
  965. ------------------------------------+---+---+---+---+---+----
  966.  az=n+ax+2*ay, -128<=n<=127
  967. ------------------------------------+---+---+---+---+---+----
  968. mul*.l #1,dx -> (nothing)           | ! | ! | Y | Y | Y | 6
  969. ------------------------------------+---+---+---+---+---+----
  970.  delete
  971. ------------------------------------+---+---+---+---+---+----
  972. mul*.l #10,dx -> add.l dx,dx        | ! | ! | ? | ? | ? | -2
  973.          move.l dx,ds        |    |   |    |   |    |
  974.          asl.l #2,dx        |    |   |    |   |    |
  975.          add.l ds,dx        |    |   |    |   |    |
  976. ------------------------------------+---+---+---+---+---+----
  977. mul*.l #12,dx -> asl.l #2,dx        | ! | ! | ? | ? | ? | -2
  978.          move.l dx,ds        |    |   |    |   |    |
  979.          add.l dx,dx        |    |   |    |   |    |
  980.          add.l ds,dx        |    |   |    |   |    |
  981. ------------------------------------+---+---+---+---+---+----
  982. mul*.l #2,dx -> add.l dx,dx        | ! | ! | ? | ? | ? | 4
  983. ------------------------------------+---+---+---+---+---+----
  984. mul*.l #3,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  985.         add.l dx,dx        |    |   |    |   |    |
  986.         add.l ds,dx        |    |   |    |   |    |
  987. ------------------------------------+---+---+---+---+---+----
  988. mul*.l #5,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  989.         asl.l #2,dx        |    |   |    |   |    |
  990.         add.l ds,dx        |    |   |    |   |    |
  991. ------------------------------------+---+---+---+---+---+----
  992. mul*.l #6,dx -> add.l dx,dx        | ! | ! | ? | ? | ? | -2
  993.         move.l dx,ds        |    |   |    |   |    |
  994.         add.l dx,dx        |    |   |    |   |    |
  995.         add.l ds,dx        |    |   |    |   |    |
  996. ------------------------------------+---+---+---+---+---+----
  997. mul*.l #7,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  998.         asl.l #3,dx        |    |   |    |   |    |
  999.         sub.l ds,dx        |    |   |    |   |    |
  1000. ------------------------------------+---+---+---+---+---+----
  1001. mul*.l #9,dx -> move.l dx,ds        | ! | ! | ? | ? | ? | 0
  1002.         asl.l #3,dx        |    |   |    |   |    |
  1003.         add.l ds,dx        |    |   |    |   |    |
  1004. ------------------------------------+---+---+---+---+---+----
  1005. mul*.l #n,dx -> moveq #m,ds         | ! | ! | ? | ? | ? | 2
  1006.         asl.l ds,dx        |    |   |    |   |    |
  1007. ------------------------------------+---+---+---+---+---+----
  1008.  n is 2^m, 8<m<14
  1009. ------------------------------------+---+---+---+---+---+----
  1010. muls.l #0,dx -> moveq #0,dx        | ! | ! | ? | ? | ? | 4
  1011. ------------------------------------+---+---+---+---+---+----
  1012. muls.l #n,dx -> asl.l #m,dx        | ! | ! | ? | ? | ? | 4
  1013. ------------------------------------+---+---+---+---+---+----
  1014.  n is 2^m, 1 <= m <= 8
  1015. ------------------------------------+---+---+---+---+---+----
  1016. muls.w #0,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 2
  1017. ------------------------------------+---+---+---+---+---+----
  1018. muls.w #1,dx -> ext.l dx        | Y | Y | ? | ? | ? | 2
  1019. ------------------------------------+---+---+---+---+---+----
  1020. muls.w #10,dx -> ext.l dx        | Y | Y | ? | ? | ? | -6
  1021.          add.l dx,dx        |    |   |    |   |    |
  1022.          move.l dx,ds        |    |   |    |   |    |
  1023.          asl.l #2,dx        |    |   |    |   |    |
  1024.          add.l ds,dx        |    |   |    |   |    |
  1025. ------------------------------------+---+---+---+---+---+----
  1026. muls.w #11,dx -> ext.l dx        | Y | Y | ? | ? | ? | -8
  1027.          move.l dx,ds        |    |   |    |   |    |
  1028.          add.l dx,dx        |    |   |    |   |    |
  1029.          add.l dx,ds        |    |   |    |   |    |
  1030.          asl.l #3,dx        |    |   |    |   |    |
  1031.          add.l ds,dx        |    |   |    |   |    |
  1032. ------------------------------------+---+---+---+---+---+----
  1033. muls.w #12,dx -> ext.l dx        | Y | Y | ? | ? | ? | -6
  1034.          asl.l #2,dx        |    |   |    |   |    |
  1035.          move.l dx,ds        |    |   |    |   |    |
  1036.          add.l dx,dx        |    |   |    |   |    |
  1037.          add.l ds,dx        |    |   |    |   |    |
  1038. ------------------------------------+---+---+---+---+---+----
  1039. muls.w #2,dx -> ext.l dx        | Y | Y | ? | ? | ? | 0
  1040.         add.l dx,dx        |    |   |    |   |    |
  1041. ------------------------------------+---+---+---+---+---+----
  1042. muls.w #3,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1043.         move.l dx,ds        |    |   |    |   |    |
  1044.         add.l dx,dx        |    |   |    |   |    |
  1045.         add.l ds,dx        |    |   |    |   |    |
  1046. ------------------------------------+---+---+---+---+---+----
  1047. muls.w #5,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1048.         move.l dx,ds        |    |   |    |   |    |
  1049.         asl.l #2,dx        |    |   |    |   |    |
  1050.         add.l ds,dx        |    |   |    |   |    |
  1051. ------------------------------------+---+---+---+---+---+----
  1052. muls.w #6,dx -> ext.l dx        | Y | Y | ? | ? | ? | -6
  1053.         add.l dx,dx        |    |   |    |   |    |
  1054.         move.l dx,ds        |    |   |    |   |    |
  1055.         add.l ds,dx        |    |   |    |   |    |
  1056.         add.l ds,dx        |    |   |    |   |    |
  1057. ------------------------------------+---+---+---+---+---+----
  1058. muls.w #7,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1059.         move.l dx,ds        |    |   |    |   |    |
  1060.         asl.l #3,dx        |    |   |    |   |    |
  1061.         sub.l ds,dx        |    |   |    |   |    |
  1062. ------------------------------------+---+---+---+---+---+----
  1063. muls.w #9,dx -> ext.l dx        | Y | Y | ? | ? | ? | -4
  1064.         move.l dx,ds        |    |   |    |   |    |
  1065.         asl.l #3,dx        |    |   |    |   |    |
  1066.         add.l ds,dx        |    |   |    |   |    |
  1067. ------------------------------------+---+---+---+---+---+----
  1068. muls.w #n,dx -> ext.l dx        | Y | Y | ? | ? | ? | 0
  1069.         asl.l #m,dx        |    |   |    |   |    |
  1070. ------------------------------------+---+---+---+---+---+----
  1071.  n is 2^m, 1 <= m <= 8
  1072. ------------------------------------+---+---+---+---+---+----
  1073. muls.w #n,dx -> moveq #m,ds        | Y | Y | ? | ? | ? | -2
  1074.         ext.l dx        |    |   |    |   |    |
  1075.         asl.l ds,dx        |    |   |    |   |    |
  1076. ------------------------------------+---+---+---+---+---+----
  1077.  n is 2^m, 8<m<14
  1078. ------------------------------------+---+---+---+---+---+----
  1079. muls.w #n,dx -> swap dx            | Y | Y | ? | ? | ? | -2
  1080.         clr.w dx        |    |   |    |   |    |
  1081.         asr.l #(16-m),dx    |    |   |    |   |    |
  1082. ------------------------------------+---+---+---+---+---+----
  1083.  n is 2^m, 8 <= m <= 15
  1084. ------------------------------------+---+---+---+---+---+----
  1085. mulu.l #0,dx -> moveq #0,dx        | ! | ! | ? | ? | ? | 4
  1086. ------------------------------------+---+---+---+---+---+----
  1087. mulu.l #n,dx -> lsl.l #m,dx        | ! | ! | ? | ? | ? | 4
  1088. ------------------------------------+---+---+---+---+---+----
  1089.  n is 2^m, 1 <= m <= ?
  1090. ------------------------------------+---+---+---+---+---+----
  1091. mulu.w #0,dx -> moveq #0,dx        | Y | Y | ? | ? | ? | 2
  1092. ------------------------------------+---+---+---+---+---+----
  1093. mulu.w #1,dx -> swap dx            | Y | Y | ? | ? | ? | -2
  1094.         clr.w dx        |    |   |    |   |    |
  1095.         swap dx            |    |   |    |   |    |
  1096. ------------------------------------+---+---+---+---+---+----
  1097. mulu.w #12,dx -> swap dx        | Y | Y | ? | ? | ? | -10
  1098.          clr.w dx        |    |   |    |   |    |
  1099.          swap dx        |    |   |    |   |    |
  1100.          asl.l #2,dx        |    |   |    |   |    |
  1101.          move.l dx,ds        |    |   |    |   |    |
  1102.          add.l dx,dx        |    |   |    |   |    |
  1103.          add.l ds,dx        |    |   |    |   |    |
  1104. ------------------------------------+---+---+---+---+---+----
  1105. mulu.w #2,dx -> swap dx         | Y | Y | ? | ? | ? | -4
  1106.         clr.w dx        |    |   |    |   |    |
  1107.         swap dx         |    |   |    |   |    |
  1108.         add.l dx,dx        |    |   |    |   |    |
  1109. ------------------------------------+---+---+---+---+---+----
  1110. mulu.w #3,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1111.         clr.w dx        |    |   |    |   |    |
  1112.         swap dx         |    |   |    |   |    |
  1113.         move.l dx,ds        |    |   |    |   |    |
  1114.         add.l dx,dx        |    |   |    |   |    |
  1115.         add.l ds,dx        |    |   |    |   |    |
  1116. ------------------------------------+---+---+---+---+---+----
  1117. mulu.w #5,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1118.         clr.w dx        |    |   |    |   |    |
  1119.         swap dx         |    |   |    |   |    |
  1120.         move.l dx,ds        |    |   |    |   |    |
  1121.         asl.l #2,dx        |    |   |    |   |    |
  1122.         add.l ds,dx        |    |   |    |   |    |
  1123. ------------------------------------+---+---+---+---+---+----
  1124. mulu.w #6,dx -> swap dx         | Y | Y | ? | ? | ? | -10
  1125.         clr.w dx        |    |   |    |   |    |
  1126.         swap dx         |    |   |    |   |    |
  1127.         add.l dx,dx        |    |   |    |   |    |
  1128.         move.l dx,ds        |    |   |    |   |    |
  1129.         add.l ds,dx        |    |   |    |   |    |
  1130.         add.l ds,dx        |    |   |    |   |    |
  1131. ------------------------------------+---+---+---+---+---+----
  1132. mulu.w #7,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1133.         clr.w dx        |    |   |    |   |    |
  1134.         swap dx         |    |   |    |   |    |
  1135.         move.l dx,ds        |    |   |    |   |    |
  1136.         asl.l #3,dx        |    |   |    |   |    |
  1137.         sub.l ds,dx        |    |   |    |   |    |
  1138. ------------------------------------+---+---+---+---+---+----
  1139. mulu.w #9,dx -> swap dx         | Y | Y | ? | ? | ? | -8
  1140.         clr.w dx        |    |   |    |   |    |
  1141.         swap dx         |    |   |    |   |    |
  1142.         move.l dx,ds        |    |   |    |   |    |
  1143.         asl.l #3,dx        |    |   |    |   |    |
  1144.         add.l ds,dx        |    |   |    |   |    |
  1145. ------------------------------------+---+---+---+---+---+----
  1146. mulu.w #n,dx -> swap dx            | Y | Y | ? | ? | ? | -4
  1147.         clr.w dx        |    |   |    |   |    |
  1148.         swap dx            |    |   |    |   |    |
  1149.         lsl.l #m,dx        |    |   |    |   |    |
  1150. ------------------------------------+---+---+---+---+---+----
  1151.  n is 2^m, 1 <= m <= 8
  1152. ------------------------------------+---+---+---+---+---+----
  1153. mulu.w #n,dx -> swap dx            | Y | Y | ? | ? | ? | -2
  1154.         clr.w dx        |    |   |    |   |    |
  1155.         lsr.l #(16-m),dx    |    |   |    |   |    |
  1156. ------------------------------------+---+---+---+---+---+----
  1157.  n is 2^m, 8 <= m <= 15
  1158. ------------------------------------+---+---+---+---+---+----
  1159. neg.x dx    -> add.x dx,dy        | Y | Y | Y | ? | ? | 2
  1160. sub.x dx,dy                |    |   |    |   |    |
  1161. ------------------------------------+---+---+---+---+---+----
  1162.  dx is trashed
  1163. ------------------------------------+---+---+---+---+---+----
  1164. neg.x dx    -> eor.x #n-1,dx        | Y | Y | ? | ? | ? | 2
  1165. add.x #n,dx                |    |   |    |   |    |
  1166. ------------------------------------+---+---+---+---+---+----
  1167.  n is 2^m, dx<n
  1168. ------------------------------------+---+---+---+---+---+----
  1169. neg.x dx    -> sub.x dx,dy        | Y | Y | Y | ? | ? | 2
  1170. add.x dx,dy                |    |   |    |   |    |
  1171. ------------------------------------+---+---+---+---+---+----
  1172.  dx is trashed
  1173. ------------------------------------+---+---+---+---+---+----
  1174. nop -> (nothing)            | Y | Y | ? | ? | ? | 2
  1175. ------------------------------------+---+---+---+---+---+----
  1176.  remove nops
  1177. ------------------------------------+---+---+---+---+---+----
  1178. or.l #n,dx -> bset.l #b,dx        | Y | Y | ? | ? | ? | 2
  1179. ------------------------------------+---+---+---+---+---+----
  1180.  n = 2^b (only 1 bit set)
  1181. ------------------------------------+---+---+---+---+---+----
  1182. sub*.x #0,dx -> tst.x dx        | Y | Y | ? | ? | ? | 2/4
  1183. ------------------------------------+---+---+---+---+---+----
  1184. sub.x #n,* -> addq.x #-n,*        | Y | Y | ? | ? | ? | 2/4
  1185. ------------------------------------+---+---+---+---+---+----
  1186.  -8 <= n <= -1
  1187. ------------------------------------+---+---+---+---+---+----
  1188. sub.x #n,* -> subq.x #n,*        | Y | Y | ? | ? | ? | 2/4
  1189. ------------------------------------+---+---+---+---+---+----
  1190.  if 1 <= n <= 8
  1191. ------------------------------------+---+---+---+---+---+----
  1192. sub.x #n,ax -> lea -n(ax),ax        | Y | Y | ? | ? | ? | 0/2
  1193. ------------------------------------+---+---+---+---+---+----
  1194.  -32767 <= n <= -9, 9 <= n <= 32767
  1195. ------------------------------------+---+---+---+---+---+----
  1196. subq.l #n,ax -> subq.w #n,ax        | Y | Y | ? | ? | ? | 0
  1197. ------------------------------------+---+---+---+---+---+----
  1198. subq.w #1,dx -> db<cc> dx,??        | y | y | ? | ? | ? | -2
  1199. b<cc> ??    b<cc> ??        |    |   |    |   |    |
  1200. ------------------------------------+---+---+---+---+---+----
  1201.  if dx=0 then will be slower
  1202. ------------------------------------+---+---+---+---+---+----
  1203. subq.w #1,dx -> dbf dx,??        | Y | Y | ? | ? | ? | -2
  1204. bra ??        bra ??            |    |   |    |   |    |
  1205. ------------------------------------+---+---+---+---+---+----
  1206.  if dx=0 then will be slower
  1207. ------------------------------------+---+---+---+---+---+----
  1208. tst.w dx -> dbra dx,??            | y | y | ? | ? | ? | 2
  1209. bne ??                    |    |   |    |   |    |
  1210. ------------------------------------+---+---+---+---+---+----
  1211.  dx will be trashed
  1212. ------------------------------------+---+---+---+---+---+----
  1213.  
  1214.  
  1215. ---------------------------------------------------------------------------
  1216.               H I N T S   &   T I P S
  1217. ---------------------------------------------------------------------------
  1218.  
  1219.  
  1220. This new section is for stuff that cannot be included in the above tables.
  1221. This can include pipelining optimizations and other stuff.
  1222.  
  1223. 020+    Sequential memory accesses can cause pipeline stalls, so try and
  1224.     rearrange code so memory accesses do not immediately follow each
  1225.     other.  The same problem occurs if an address register updated
  1226.     in one line is accessed in the next line.
  1227.  
  1228. ALL    Include small routines as macros, because inline routines will
  1229.     be much faster, and in extreme cases smaller.
  1230.  
  1231. ALL    If a subroutine is only called from one position, either move
  1232.     it inline, or only use jmp/bra commands.
  1233.  
  1234.  
  1235. ---------------------------------------------------------------------------
  1236.                 C O N C L U S I O N
  1237. ---------------------------------------------------------------------------
  1238.  
  1239.  
  1240. There are the optimizations i've come up with so far.  If you could check
  1241. what i've done, and report any errors, that would make this list better.  I
  1242. only have so much time to spend on this, and many hands make light work.
  1243. Also, stats (and more optimizations) for 68020+ CPU's would be welcomed.
  1244. Currently this list is only for simple peephole optimization stuff, but I
  1245. will hopefully get around to more extensive optimizations.  Pipeline
  1246. optimization is on the way, so look out.  Any info on the 68020+ pipelines
  1247. would be appreciated.
  1248.  
  1249. Optimizations with ?question-marks? in the boxes next to them, I do not
  1250. have the data to check yet.
  1251.  
  1252. The latest version of the asp68k archive is available by anonymous ftp from
  1253. ftp.mq.edu.au in the /home/mglew/ directory or by calling Technophilia BBS
  1254. on +61 2 807 3563 (or (02) 807 3563 in Australia).
  1255.  
  1256.  
  1257. ===========================================================================
  1258. EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF EOF
  1259. ===========================================================================
  1260.  
  1261.